script_enemy_main{

let SEshotm6=("script\SoundEffects\shotm6.wav");
let SEshotb1=("script\SoundEffects\shotb1.wav");

let type=GetArgument[0];
let angle=GetArgument[1];
let color=GetArgument[2];
color=(color-1)*40;
let grow=0;

SetAngle(angle);
SetSpeed(3);

angle=rand(0,360);

let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots5=("script\SoundEffects\shots5.wav");

let SEdeath=("script\SoundEffects\enemydeath1.wav");
let GRfamiliar=("\script\Images\OtherEffects\Chips.png");

@Initialize{
	LoadSE("script\SoundEffects\shots5.wav");

	LoadSE("script\SoundEffects\enemydeath1.wav");
	LoadGraphic("\script\Images\OtherEffects\Chips.png");

	SetScore(100);
	SetLife(15);
	SetDamageRate(10,10);
	MagicCircle(false);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,grow*18);
SetCollisionB(GetX,GetY,grow*18);

if(GetX<=minx-32 || GetX>=maxx+32 || GetY<=miny-32 || GetY>=maxy+32 && time>=60){ VanishEnemy; }

let shotcolor=0;
if(GetArgument[2]==1){ shotcolor=1; }
if(GetArgument[2]==2){ shotcolor=2; }
if(GetArgument[2]==3){ shotcolor=3; }
if(GetArgument[2]==4){ shotcolor=5; }
if(GetArgument[2]==5){ shotcolor=8; }
if(GetArgument[2]==6){ shotcolor=9; }


//=============================================================

if(GetCommonData("Difficulty")==2){
	if(type==1){
		if(time%25==0){
		let angle=rand(0,360);
		let shot1=0;
			loop(8){
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,angle,0,0.008,0.9,48+shotcolor);
			FireShot(shot1);
			angle+=360/8;
			}
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if(time%6==0){
			let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+120*cos(angle),0,0.008,0.9,48+shotcolor);
			FireShot(shot1);
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-120*cos(angle),0,0.008,0.9,48+shotcolor);
			FireShot(shot1);
		angle+=17;
		PlaySE(SEshots5);
		}
	}
} //Normal

//=============================================================

if(GetCommonData("Difficulty")==3){
	if(type==1){
		if(time%20==0){
		let angle=rand(0,360);
		let shot1=0;
			loop(7){
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,angle,0,0.008,1,48+shotcolor);
			FireShot(shot1);
			angle+=360/7;
			}
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if(time%6==0){
			let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+120*cos(angle),0,0.008,1,48+shotcolor);
			FireShot(shot1);
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-120*cos(angle),0,0.008,1,48+shotcolor);
			FireShot(shot1);
		angle+=17;
		PlaySE(SEshots5);
		}
	}
} //Hard

//=============================================================

if(GetCommonData("Difficulty")==4){
	if(type==1){
		if(time%16==0){
		let angle=rand(0,360);
		let shot1=0;
			loop(6){
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,angle,0,0.008,1.1,48+shotcolor);
			FireShot(shot1);
			angle+=360/6;
			}
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if(time%6==0){
			let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+120*cos(angle),0,0.008,1.1,48+shotcolor);
			FireShot(shot1);
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-120*cos(angle),0,0.008,1.1,48+shotcolor);
			FireShot(shot1);
		angle+=17;
		PlaySE(SEshots5);
		}
	}
} //Lunatic




if(grow<1){ grow+=0.1; }
if(grow>=1){ grow=1; }


time++;
frame++;

}

@DrawLoop{
	SetGraphicScale(grow,grow);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*5);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicRect(0+color,0,40+color,40);
	DrawGraphic(GetX,GetY);
}

@Finalize{
if(BeVanished==false){ PlaySE(SEdeath); DeleteEnemyShotInCircle(SHOT,GetX,GetY,30); }
}

}